#define _CRT_SECURE_NO_WARNINGS 1
#include "BTree.h"
#include "Queue.h"

BTNode* BuyNode(BTDataType x)
{
	BTNode* BT = (BTNode*)malloc(sizeof(BTNode));
	if (BT == NULL)
	{
		perror("malloc fail!\n");
		exit(1);
	}
	BT->data = x;
	BT->left = NULL;
	BT->right = NULL;
	return BT;
}

BTNode* CreateBinaryTree()
{
	BTNode* node1 = BuyNode(1);
	BTNode* node2 = BuyNode(2);
	BTNode* node3 = BuyNode(3);
	BTNode* node4 = BuyNode(4);
	BTNode* node5 = BuyNode(5);
	BTNode* node6 = BuyNode(6);

	node1->left = node2;
	node1->right = node4;
	node2->left = node3;
	node4->left = node5;
	node4->right = node6;
	return node1;
}

int main()
{
	BTNode* root = CreateBinaryTree();
	//PreOrder(root);
	//printf("\n");
	//InOrder(root);
	//printf("\n");
	//PostOrder(root);	
	//printf("\n");
	//LevelOrder(root);
	//printf("\n");
	

	//printf("节点个数 = %d\n", BinaryTreeSize(root));
	//printf("叶子节点个数 = %d\n", BinaryTreeLeafSize(root));
	//printf("数的高度 = %d\n", BinaryTreeHeight(root));
	//printf("是否为完全二叉树(是1 不是0) = %d\n", BinaryTreeComplete(root));
	
	//int k = 0;
	//scanf("%d", &k);
	//printf("第k层节点个数 = %d\n", BinaryTreeLevelKSize(root, k));
	//printf("值为x的地址 = %p\n", BinaryTreeFind(root, 4));
	

	BinaryTreeDestory1(&root);
	//BinaryTreeDestory2(root);
	//root = NULL;
	return 0;
}